package LuoGu;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class P3613 {
    public static void main(String[] args) throws IOException {
        StreamTokenizer st=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        st.nextToken();
        int n=(int)st.nval;
        int[][] arr=new int[n+1][10000];
        st.nextToken();
        int len=0;
        int num1=(int)st.nval;
        int[] f=new int[n+1];
        for (int i = 0; i < num1; i++) {
            st.nextToken();
            int is=(int)st.nval;
            st.nextToken();
            int gui=(int)st.nval;
            st.nextToken();
            int ge=(int)st.nval;
            if(is==1){
                st.nextToken();
                int k=(int)st.nval;
                if(k==0){
                    arr[gui][ge]=0;
                }else{
                    arr[gui][ge]=k;
                }

            }else{
               f[len++]=arr[gui][ge];
            }
        }
        for (int i = 0; i < len; i++) {
            System.out.println(f[i]);
        }
    }
}
